package com.acctrue.zentao.utils;

/**
 * 字符串工具类
 *
 * @author: 孙炯炯
 * @since: 2023/8/18
 **/
public class StringUtils {

    public static boolean isNotEmpty(CharSequence cs) {
        return !isEmpty(cs);
    }

    public static boolean isEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }

    public static String getString(char[] str) {
        if (str == null || str.length == 0) {
            return "";
        }
        return new String(str);
    }

    public static String getString(String str) {
        if (isEmpty(str)) {
            return "";
        }
        return str.trim();
    }

    public static String getString(Object object) {
        if (object == null) {
            return "";
        }
        String str = object.toString();
        if (str.startsWith("\"") && str.endsWith("\"") && str.length() > 1) {
            return str.replace("\"", "");
        }
        return str;
    }
}
